package com.sunshine.wheel.study.netty.chat.util;

import java.io.File;

public class FileUtils {

    /**
     * 获取文件
     * @param baseUri       基础路径
     * @param fileName      文件名称
     * @return
     */
    public static File getFile(String baseUri, String fileName) {
        if (baseUri ==null || fileName == null) {
            return null;
        }
        baseUri = baseUri.endsWith("/") ? baseUri : baseUri + "/";
        fileName = fileName.startsWith("/") ? fileName.substring(1) : fileName;
        String finalPath = baseUri + fileName;
        finalPath = finalPath.contains("file:") ? finalPath.substring(5) : finalPath;
        finalPath = finalPath.replaceAll("//", "/");
        return new File(finalPath);
    }

}
